package com.xiaojie.dubbo.server.discover;

import org.I0Itec.zkclient.ZkClient;

import java.util.List;

public class ServiceDiscoverImpl  implements  ServiceDiscover{
    //定义zk地址
    private String zkServer="192.168.6.136:2181";
    //超时时间
    private Integer timeOut=5000;
    //zkclient
    private ZkClient zkClient;

    public ServiceDiscoverImpl() {
        zkClient = new ZkClient(zkServer,timeOut);
    }

    //定义跟节点
    private  String rootNode="/xiaojie-dubbo";
    @Override
    public List<String> discoverList(String serviceName) {
        List<String> children = zkClient.getChildren(rootNode + "/" + serviceName + "/" + "providers");
        return children;
    }
}
